package com.itheima.socket.ip.inetaddress;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 如何去使用这个InetAddress这个类，来表示我们的ip地址；主要学习的就是如何获取这个类的实例对象
 */
public class InetAddressDemo01 {

    public static void main(String[] args) throws UnknownHostException {

        // public static InetAddress getByName(String host)：host主机名或者ip地址字符串
        // InetAddress inetAddress = InetAddress.getByName("DESKTOP-IK2ANEF");
        InetAddress inetAddress = InetAddress.getByName("192.168.19.27");

        // 调用InetAddress的方法获取一些信息
        // public String getHostName(): 获取主机名称
         System.out.println(inetAddress.getHostName());

        // public String getHostAddress(): 获取主机地址
         System.out.println(inetAddress.getHostAddress());

    }


}
